﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using Gao.Poker.Domain;
using Gao.Poker.Services;

namespace Gao.Poker.Command
{
    public class CompetitionSaveCommand : BaseCommand
    {
        private readonly Action<Boolean, Competition> _action;

        public CompetitionSaveCommand(Action<Boolean, Competition> action)
        {
            _action = action;
        }

        public override void Execute(object parameter)
        {
            Competition member = parameter as Competition;
            CompetitionService service = new CompetitionService();
            parameter = service.Save(member);
            if(_action != null)
            {
                _action(parameter != null, member);
            }
        }
    }
}
